<?php
/**
 * Created by PhpStorm.
 * User: Mak
 * Date: 2016/2/6
 * Time: 19:13
 */

namespace Home\Controller;
use Org\Util\Snoopy;
use Think\Controller;

class CjController extends Controller{

    public function _initialize(){
        header("content-type:text/html; charset=utf-8");
        $flag = session("?Account");
        if(!$flag){
            $this->error("非法登录",U('Home/Index/index'));
        }
    }

    public function index(){
        $sn=new Snoopy();
        $Account=session("Account");
        $sn->cookies= session("cookies");
  //      dump(session("cookies"));
        $sn->proxy_host=session("ip.ip");
        $sn->proxy_port=session("ip.port");
        $sn->agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko";
        $sn->referer = "http://jw.gxsdxy.cn/jiaowures/";
        $sn->rawheaders['Pragma'] = 'no-cache';
        $sn->rawheaders['X_FORWARDED_FOR'] = "jw.gxsdxy.cn";
        $sn->fetch("http://jw.gxsdxy.cn/jiaowures/JWXS/cjcx/jwxs_cjcx_like.aspx?usermain=x{$Account}");

        $ret=mb_convert_encoding($sn->results,"utf-8","gb2312");
        $pattern = '/<table id="cjxx" cellspacing="0" cellpadding="0" border="1" bordercolorlight="#588FC7" bordercolordark="#ffffff" bordercolor="#588FC7" border="0" style="border-color:#588FC7;width:100%;border-collapse:collapse;">(.*?)<\/table> /is';
        preg_match_all($pattern, $ret, $matches);

        $this->assign("cj",$matches[1][0]);
        $this->assign("title","查询成绩");
        $this->display();
    }
}
